﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TestGenerator
{
    class Test
    {
        QuestionData qD;

        public Test(Settings settings)
        {
        qD = new QuestionData(settings.InputFileName);
          
        }

        public void GenerateNext()
        {
            ArrayShuffle.Shuffle(qD.Questions);            
        }

        public string ToString(Settings settings,int variant,  List<char> correctList)
        {
 
            StringBuilder output = new StringBuilder(qD.header.Replace("# # #",variant.ToString("0 0 0")));
           
            for (int i = 0; i < qD.Questions.Count && i < settings.MaxQuestionsCount; i++)
            {
                char correct;
                output.Append( qD.Questions[i].ToString(settings,i+1,out correct));
                output.Append('\n');
                correctList.Add(correct);
            }
            output.Append(qD.footer);
            return output.ToString();
        }

    }
}
